package kr.ltkblue;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class Main{
	public static void main(String[] args) throws Exception {

		Document doc = Jsoup.connect("http://nonghyup.chzero.com/list_branch.jsp").get();
		Elements titles = doc.select("ul#sub_map  li  a");

		UrlConn urlConn = new UrlConn();
		boolean emptyTable = true;
		//print all titles in main page
//		for(Element e: titles){
//			urlConn.insertData(e.text().substring(0,2),e.text(),emptyTable);
//			System.out.println("text: " +e.text());
//			System.out.println("text: " +e.text().substring(0,2));
//			emptyTable=false;
////			System.out.println("html: "+ e.html());
//		}
		
		String areaArray[][] = {
				{"서울특별시","서울"}
				,{"경기도","경기"}
				,{"강원도","강원"}
				,{"경상남도","경남"}
				,{"경상북도","경북"}
				,{"광주광역시","광주"}
				,{"대구광역시","대구"}
				,{"대전광역시","대전"}
				,{"부산광역시","부산"}
				,{"세종특별시","세종"}
				,{"울산광역시","울산"}
				,{"인천광역시","인천"}
				,{"전라남도","전남"}
				,{"전라북도","전북"}
				,{"제주도","제주"}
				,{"충청남도","충남"}
				,{"충청북도","충북"}
		
		};
		
		for (int i = 0; i < areaArray.length; i++) {
			System.out.println(areaArray[i][0]+" :  "+areaArray[i][1]);
			if(i!=0){
				emptyTable=false;
			}
			urlConn.insertData(areaArray[i][1],areaArray[i][0],emptyTable);
			
		}
		

		//print all available links on page
//		Elements links = doc.select("a[href]");
//		for(Element l: links){
//			System.out.println("link: " +l.attr("abs:href"));
//		}

	}
}
